package homework;

import java.time.DayOfWeek;
import java.time.LocalDate;
import java.time.Period;
import java.time.temporal.ChronoUnit;
import java.util.Scanner;

public class BirthdayCalculator {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.print("请输入生日(yyyy-mm-dd): ");
        LocalDate birthday = LocalDate.parse(scanner.next());

        LocalDate today = LocalDate.now();

        // 计算年龄
        int age = Period.between(birthday, today).getYears();
        System.out.println("当前年龄: " + age);

        // 下次生日
        LocalDate nextBirthday = birthday.withYear(today.getYear());
        if (nextBirthday.isBefore(today) || nextBirthday.isEqual(today)) {
            nextBirthday = nextBirthday.plusYears(1);
        }
        long daysUntilBirthday = ChronoUnit.DAYS.between(today, nextBirthday);
        System.out.println("距离下次生日天数: " + daysUntilBirthday);

        // 出生星期几
        DayOfWeek dayOfWeek = birthday.getDayOfWeek();
        System.out.println("出生日期为: " + dayOfWeek);

        // 是否闰年
        boolean isLeapYear = birthday.isLeapYear();
        System.out.println("是否闰年出生: " + isLeapYear);
    }
}
